package com.paoyx.ydnote;

import android.os.Bundle;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
import com.actionbarsherlock.view.SubMenu;
import com.paoyx.ydnote.adapter.MainFragmentAdapter;
import com.viewpagerindicator.TabPageIndicator;

public class MainActivity extends SherlockFragmentActivity{
    private View mainActionBarView;
    private FragmentPagerAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        initActionBar();
        initView();
        
    }
    
    private void initView() {
        // TODO Auto-generated method stub
        adapter = new MainFragmentAdapter(getSupportFragmentManager(), this);
        ViewPager pager = (ViewPager) findViewById(R.id.pager);
        pager.setAdapter(adapter);
        TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
        indicator.setViewPager(pager);
    }

    private void initActionBar() {
        //可以自定义actionbar
        getSupportActionBar().setDisplayShowCustomEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        //不在actionbar显示logo
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setBackgroundDrawable(
                getResources().getDrawable(R.drawable.actionbar_tab_bg));
        //this死
        mainActionBarView = LayoutInflater.from(this).inflate(R.layout.main_action_bar, null);
        
        getSupportActionBar().setCustomView(mainActionBarView);
    
    }

  /*  @Override
    public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
        // TODO Auto-generated method stub
        MenuItem ads = menu.add("ads");
        ads.setIcon(R.drawable.menu_apprec);
        ads.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        ads.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                // TODO Auto-generated method stub
                Toast.makeText(MainActivity.this, "这个是广告。。。", Toast.LENGTH_LONG).show();
                return false;
            }
        });
       
        SubMenu subMenu = menu.addSubMenu("Action Item");
        subMenu.add("推荐给好友");
        subMenu.add("关于");
        subMenu.add("登录");
        subMenu.add("退出");
        MenuItem subMenuItem = subMenu.getItem();
        subMenuItem.setIcon(R.drawable.abs__ic_menu_moreoverflow_holo_light);
        subMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        
        
        return super.onCreateOptionsMenu(subMenu);
    }
*/
    
    
}
